using System;
using Gtk;
using System.IO;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenMetaverse.StructuredData;

public partial class MainWindow : Gtk.Window
{
	public static GridClient client = new GridClient();
	private static string first_name = "Alice";
	private static string last_name = "Bot";
	private static string password = "000";
	public static string m_message, m_fail;
	private static bool loggedIn;
	
	public MainWindow () : base(Gtk.WindowType.Toplevel)
	{
		loggedIn = false;
		Build ();
		client.Settings.LOGIN_SERVER = "http://127.0.0.1:9000/";
		client.Network.LoginProgress += new EventHandler<LoginProgressEventArgs>(Network_LoginProgress);
		client.Network.Login(first_name, last_name, password, "CLIENT", "", "Team");
		Console.WriteLine("-->>>>> Login Message: " + client.Network.LoginMessage);
	}

	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
	{
		Application.Quit ();
		a.RetVal = true;
	}
	protected virtual void OnButton2Pressed (object sender, System.EventArgs e)
	{
		//this.Iconify ();
		Console.WriteLine("The bot is alive");
		if (loggedIn) {
			Console.WriteLine("Bot logged in");
		} else {
			Console.WriteLine("Bot logged out");
		}
	}
	
	void Network_LoginProgress(object sender, LoginProgressEventArgs e)
    {
        if (e.Status == LoginStatus.Success)
        {
            loggedIn = true;
        }
    }
	
}

